﻿using Engine;
using TemplatesDatabase;

namespace Game
{
    public class Zhixue : SubsystemBlockBehavior
    {
        public SubsystemAudio m_subsystemAudio;

        public Random m_random = new Random();

        public ComponentHealth componentHealth;

        public ComponentVitalStats componentVitalStats;

        public SubsystemTerrain m_subsystemTerrain;

        public override int[] HandledBlocks => new int[1] { 313 };

        public override bool OnUse(Ray3 ray, ComponentMiner componentMiner)
        {
            m_subsystemAudio.PlaySound("Audio/Piston", 1f, m_random.Float(-0.1f, 0.1f), 0f, 0f);
            ComponentPlayer componentPlayer = componentMiner.ComponentPlayer;
            if (componentPlayer != null)
            {
                componentPlayer.ComponentHealth.Heal(0.3f);
                componentPlayer.ComponentVitalStats.Stamina = 1f;
                componentPlayer.ComponentGui.DisplaySmallMessage("你包扎了伤口，止住了血…", Color.White, blinking: true, playNotificationSound: true);
            }

            componentMiner.RemoveActiveTool(1);
            return true;
        }

        public override void Load(ValuesDictionary valuesDictionary)
        {
            base.Load(valuesDictionary);
            m_subsystemTerrain = base.Project.FindSubsystem<SubsystemTerrain>(throwOnError: true);
            m_subsystemAudio = base.Project.FindSubsystem<SubsystemAudio>(throwOnError: true);
        }
    }
}